#include <stdint.h>
#include "ursax.h"
#include "log.h"
#include "identity-pool.h"
#include "ringbuffer.h"

class MemoryPool
{
public:
	MemoryPool() { LOG_DEBUG("run"); }
	virtual ~MemoryPool() { LOG_DEBUG("run"); }
	virtual void* pmalloc(uint32_t size) = 0;
	virtual void pfree(void* p) = 0;
};

class IdentityPool : public MemoryPool
{
	struct identity_pool *id_pool;
	int unit_size;
public:
	IdentityPool();
	IdentityPool(int capacity, Ctor ctor, Dtor dtor, int unit_size);
	~IdentityPool();
	void* pmalloc(uint32_t size);
	void pfree(void* p);
};

class RingBuffer : public MemoryPool
{
	ursax_ringbuf *ringbuf;
public:
	RingBuffer();
	RingBuffer(uint64_t ring_size, uint64_t alignment, void* ptr);
	~RingBuffer();
	void* pmalloc(uint32_t size);
	void pfree(void* p);
};

